import { service } from "./request.js";

const getRoleList = (data) => {
  return service({
    url: "/sysUser/getSysUsers",
    method: "post",
    data,
  });
};

const addSysUser = (data) => {
  return service({
    url: "/sysUser/addSysUser",
    method: "post",
    data,
  });
};

const editSysUser = (data) => {
  return service({
    url: "/sysUser/modifySysUserCommon",
    method: "post",
    data,
  });
};

const modifyPassword = (data) => {
  return service({
    url: "/sysUser/modifySysUserLoginPwdMe",
    method: "post",
    data,
  });
};
const resetPassword = (data) => {
  return service({
    url: "/sysUser/modifySysUserLoginPwdOther",
    method: "post",
    data,
  });
};
// 获取角色列表
const getRoles = (data) => {
  return service({
    url: "/sysRbac/getSysRoles",
    method: "post",
    data,
  });
};
//获取某个用户的角色列表
const getRolesByUser = (data) => {
  return service({
    url: "/rbac/getRolesByUser",
    method: "post",
    data,
  });
};

const assignRolesToUser = (data) => {
  return service({
    url: "/rbac/assignRolesToUser",
    method: "post",
    data,
  });
};

const frozenUser = (data) => {
  return service({
    url: "/sysUser/modifySysUserFrozen",
    method: "post",
    data,
  });
};

const removeRole = (data) => {
  return service({
    url: "/rbac/revokeRolesFromUser",
    method: "post",
    data,
  });
};
//修改角色
const modifyRoleCommon = (data) => {
  return service({
    url: "/rbac/modifyRoleCommon",
    method: "post",
    data,
  });
};

//新增角色
const addroles = (data) => {
  return service({
    url: "/rbac/addRole",
    method: "post",
    data,
  });
};
//修改角色启用或者禁用
const modifyRoleEnable = (data) => {
  return service({
    url: "/sysRbac/modifySysRoleEnable",
    method: "post",
    data,
  });
};

const addAccess = (data) => {
  return service({
    url: "/rbac/addAccess",
    method: "post",
    data,
  });
};
//获取通道权限列表

const getAccesses = (data) => {
  return service({
    url: "/sysRbac/getSysAccesses",
    method: "post",
    data,
  });
};
const modifyAccessCommon = (data) => {
  return service({
    url: "/rbac/modifyAccessCommon",
    method: "post",
    data,
  });
};
//根据角色id获取通道权限
const getAccessesByRole = (data) => {
  return service({
    url: "/rbac/getAccessesByRole",
    method: "post",
    data,
  });
};
//绑定 通道权限 到角色
const assignAccessesToRole = (data) => {
  return service({
    url: "/rbac/assignAccessesToRole",
    method: "post",
    data,
  });
};
//删除某个角色的通道权限
const revokeAccessesFromRole = (data) => {
  return service({
    url: "/rbac/revokeAccessesFromRole",
    method: "post",
    data,
  });
};
//删除角色
const deleteRole = (data) => {
  return service({
    url: "/rbac/deleteRole",
    method: "post",
    data,
  });
};

const deleteUser = (data) => {
  return service({
    url: "/sysUser/deleteSysUser",
    method: "post",
    data,
  });
};

//删除通道权限
const deleteAccess = (data) => {
  return service({
    url: "/rbac/deleteAccess",
    method: "post",
    data,
  });
};
// 审批流 上传附件
const uploadFile = (data) => {
  return service({
    url: "/auditBizInfo/upload",
    method: "post",
    data,
  });
};
// 审批流 创建审核业务+上传附件
const createAuditBiz = (data) => {
  return service({
    url: "/auditBizInfo/createAuditBiz",
    method: "post",
    data,
  });
};
// 审批流 查询流程定义
const queryProcessDefinitions = (params) => {
  return service({
    url: "/bpmn/queryProcessDefinitions",
    method: "get",
    params,
  });
};
// 审批流 创建一个流程实例（创建之后将自动执行活动并进入到第一个任务）
const createProcessInstance = (data) => {
  return service({
    url: "/bpmn/createProcessInstance",
    method: "post",
    data,
  });
};
// 审批流 查询运行中的流程实例
const queryRunningProcessInstances = (params) => {
  return service({
    url: "/bpmn/queryRunningProcessInstances",
    method: "get",
    params,
  });
};
// 审批流 查询运行中的任务
const queryRunningTasks = () => {
  return service({
    url: "/bpmn/queryRunningTasks",
    method: "get",
  });
};
// 审批流 审核通过流程实例的当前任务
const approveTask = (params) => {
  return service({
    url: "/bpmn/approveTask",
    method: "get",
    params,
  });
};
// 审批流 驳回流程实例到上一个任务环节
const bpmnReject = (params) => {
  return service({
    url: "/bpmn/reject",
    method: "get",
    params,
  });
};
// 审批流 获取审核详细信息--携带附件
const getDeatilById = (params) => {
  return service({
    url: "/auditBizInfo/getDeatilById",
    method: "get",
    params,
  });
};
// 审批流 任务
const queryTasks = (params) => {
  return service({
    url: "/bpmn/queryTasks",
    method: "get",
    params,
  });
};
// 审批流 查询流程实例
const queryProcessInstances = (params) => {
  return service({
    url: "/bpmn/queryProcessInstances",
    method: "get",
    params,
  });
};

export {
  getRoleList,
  addSysUser,
  editSysUser,
  modifyPassword,
  resetPassword,
  getRoles,
  getRolesByUser,
  assignRolesToUser,
  frozenUser,
  removeRole,
  modifyRoleCommon,
  addroles,
  modifyRoleEnable,
  addAccess,
  getAccesses,
  modifyAccessCommon,
  getAccessesByRole,
  assignAccessesToRole,
  revokeAccessesFromRole,
  deleteRole,
  deleteUser,
  deleteAccess,
  uploadFile,
  createAuditBiz,
  queryProcessDefinitions,
  createProcessInstance,
  queryRunningProcessInstances,
  queryRunningTasks,
  approveTask,
  bpmnReject,
  getDeatilById,
  queryTasks,
  queryProcessInstances,
};
